package com.yinhe.music.yhmusic.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.yinhe.music.yhmusic.constants.IConstants;
import com.yinhe.music.yhmusic.search.MenuListFragment;
import com.yinhe.music.yhmusic.search.RadioListFragment;
import com.yinhe.music.yhmusic.singer.SingerDetailFragment;

/**
 * Created by hasee on 2017/3/2.
 */

public class UserInfoAdapter extends FragmentPagerAdapter {
    private String intro;
    private String userId;

    public UserInfoAdapter(FragmentManager fm, String intro, String userId) {
        super(fm);
        this.intro = intro;
        this.userId = userId;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = MenuListFragment.newInstance(null, IConstants.USER_SONG_MENU, userId);
                break;
            case 1:
                fragment = RadioListFragment.newInstance(null, IConstants.USER_RADIO_LIST, userId);
                break;
            case 2:
                fragment = SingerDetailFragment.newInstance(intro, IConstants.USER_DETAIL);
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return "歌单";
            case 1:
                return "电台";
            case 2:
                return "简介";
            default:
                break;
        }
        return null;
    }
}
